#ifndef _FEC_NORM_ENCODER_RS16
#define _FEC_NORM_ENCODER_RS16

#include "fecEncoder.h"
namespace Fec
{
class FecEncoderRS16 : public FecEncoder
{
    public:
	    FecEncoderRS16();
	    ~FecEncoderRS16();
        
        virtual bool Init(unsigned int numData, unsigned int numParity, uint16_t vectorSize);
        virtual void Destroy();
        virtual void Encode(unsigned int segmentId, const char* dataVector, char** parityVectorList, unsigned int numData = 0);    
        
        unsigned int GetNumData() 
            {return ndata;}
	    unsigned int GetNumParity() 
            {return npar;}
	    unsigned int GetVectorSize() 
            {return vector_size;}
	
    private:
        unsigned int    ndata;        // max data pkts per block (k)
	    unsigned int    npar;	      // No. of parity packets (n-k)
	    unsigned int    vector_size;  // Size of biggest vector to encode
        uint8_t*          enc_matrix;
        unsigned int    enc_index;
        
};  // end class NormEncoderRS16


class FecDecoderRS16 : public FecDecoder
{
    public:
	    FecDecoderRS16();
        virtual ~FecDecoderRS16();
        virtual bool Init(unsigned int numData, unsigned int numParity, uint16_t vectorSize);
        virtual void Destroy();
        virtual int Decode(char** vectorList, unsigned int numData,  unsigned int erasureCount, unsigned int* erasureLocs);
        
        unsigned int GetNumParity() 
            {return npar;}
	    unsigned int GetVectorSize() 
            {return vector_size;}
        
    private:
        bool InvertDecodingMatrix();   // used in Decode() method
            
        unsigned int    ndata;        // max data pkts per block (k)
	    unsigned int    npar;	      // No. of parity packets (n-k)
	    uint16_t          vector_size;  // Size of biggest vector to encode
        uint8_t*          enc_matrix;
        uint8_t*          dec_matrix;
        unsigned int*   parity_loc;
        
        // These "inv_" members are used in InvertDecodingMatrix()
        unsigned int*   inv_ndxc;
        unsigned int*   inv_ndxr;
        unsigned int*   inv_pivt;   
        uint8_t*          inv_id_row;
        uint8_t*          inv_temp_row;
             
};  // end class NormDecoderRS16


#endif // _NORM_ENCODER_RS16
}